package controllers.api;

import java.util.HashMap;
import java.util.List;
import java.util.Map;


import models.Massage;
import models.User;

public class Massages extends API {
	public static void SendMsg(){
		Map<String, Object> args = new HashMap<String, Object>();
		Massage msg=new Massage();
		String text=request.params.get("text");
		String to="4fa155b4d55b2396ab513c67";
		String uid=session.get("sessionUser");
		msg.setFrom(uid);
		msg.setTo(to);
		msg.setText(text);
		msg.save();
		User userTo=User.find("by_id",msg.getTo()).first();
		User userFrom=User.find("by_id",msg.getFrom()).first();
		//args.put("msgText",msg.getText());
		args.put("userTo",userTo);
		args.put("userFrom",userFrom);
		//json(msg);
	}
	public static void list(){
		List<Massage> msg = Massage.find().fetch();
		json(msg);
	}
}
